<!DOCTYPE html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="../common.jsp"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html lang="en">
    <head>        
    	<base href="<%=basePath%>">
        <!-- META SECTION -->
        <title>${htmlTitle}</title>            
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        
        <link rel="icon" href="favicon.ico" type="image/x-icon" />
        <!-- END META SECTION -->
    </head>
    <body>
    
    	<%@include file="../header.jsp"%>
    
        <!-- START PAGE CONTAINER -->
        <div class="page-container">
            
            <!-- START PAGE SIDEBAR -->
            	<%@include file="../left.jsp"%>
            <!-- END PAGE SIDEBAR -->
            
            <!-- PAGE CONTENT -->
            <div class="page-content">

                <!-- START BREADCRUMB -->
                <%=request.getAttribute("navigation") %> 
                <!-- END BREADCRUMB -->       
                
                <!-- START CONTENT FRAME -->
				<!-- END  CONTENT FRAME -->                
                
                <!-- PAGE CONTENT WRAPPER -->
                <div class="page-content-wrap">
					<div class="row">
						<div class="col-md-12" style="padding-top: 10px;">
							<form id="jvalidate" role="form" action="<%=basePath%>estate/saveOrUpdateWechat" class="form-horizontal" method="post" enctype="multipart/form-data">
								<div class="panel panel-default">
									<div class="panel-body" style="border: none;">
									
										<input id="menuId" name="menuId" value="${currMenuId }" type="hidden" />
									
										<div class="form-group">
											<label class="col-md-3 col-xs-12 control-label">
												公众号名称
											</label>
											<div class="col-md-6 col-xs-12">
												<input id="id" name="id" value="${estateWechat.id }" type="hidden" />
												<input id="estateId" name="estateId" value="${estateId }" type="hidden" />
												<input id="name" name="name" value="${estateWechat.name }" type="text" class="form-control" placeholder="请输入公众号名称"/>
											</div>
										</div>
										
										<div class="form-group">
											<label class="col-md-3 col-xs-12 control-label">
												开发者微信号
											</label>
											<div class="col-md-6 col-xs-12">
												<input id="developerId" name="developerId" value="${estateWechat.developerId }" type="text" class="form-control" placeholder="请输入开发者微信号"/>
											</div>
										</div>
										
										<div class="form-group">
											<label class="col-md-3 col-xs-12 control-label">
												商户号
											</label>
											<div class="col-md-6 col-xs-12">
												<input id="mchId" name="mchId" value="${estateWechat.mchId }" type="text" class="form-control" placeholder="请输入商户号"/>
											</div>
										</div>
										
										<div class="form-group">
											<label class="col-md-3 col-xs-12 control-label">
												Token(令牌)
											</label>
											<div class="col-md-6 col-xs-12">
												<input id="token" name="token" value="${estateWechat.token }" type="text" class="form-control" placeholder="请输入Token(令牌)"/>
											</div>
										</div>
										
										<div class="form-group">
											<label class="col-md-3 col-xs-12 control-label">
												AppID(应用ID)
											</label>
											<div class="col-md-6 col-xs-12">
												<input id="appId" name="appId" value="${estateWechat.appId }" type="text" class="form-control" placeholder="请输入AppID(应用ID)"/>
											</div>
										</div>
										
										<div class="form-group">
											<label class="col-md-3 col-xs-12 control-label">
												AppSecret(应用密钥)
											</label>
											<div class="col-md-6 col-xs-12">
												<input id="appSecret" name="appSecret" value="${estateWechat.appSecret }" type="text" class="form-control" placeholder="请输入AppSecret(应用密钥)"/>
											</div>
										</div>
										
										<div class="form-group" >
											<label class="col-md-3 col-xs-12 control-label">
												KeySecret(支付密钥)
											</label>
											<div class="col-md-6 col-xs-12">
												<input id="keySecret" name="keySecret" value="${estateWechat.keySecret }" type="text" class="form-control" placeholder="请输入KeySecret(支付密钥)"/>
											</div>
										</div>
										
									</div>
									<div class="panel-footer pull-center"
										style="text-align: center">
										<button class="btn btn-primary" type="button" onclick="back()">
											取消
										</button>
										<button class="btn btn-primary"  type="submit" >
											<c:if test="${isUpdate == 0}">
												确认新增
											</c:if>
											<c:if test="${isUpdate == 1}">
												确认修改
											</c:if>
										</button>
									</div>
								</div>
							</form>
						</div>
					</div>
                </div>
                <!-- END PAGE CONTENT WRAPPER -->                                
            </div>            
            <!-- END PAGE CONTENT -->
        </div>
        <!-- END PAGE CONTAINER -->
        
        <script type="text/javascript">
        
        	$(document).ready(function() {
        		validate();
        		init();
			});
        	
        	function validate() {
        		var jvalidate = $("#jvalidate").validate({
	                ignore: [],
	                rules: {                                            
	                        name: {
	                                required: true
	                        },
	                        developerId: {
	                                required: true
	                        },
	                        mchId: {
	                                required: true
	                        },
	                        token: {
	                                required: true
	                        },
	                        appId: {
                                required: true
                        	},
                        	appSecret: {
                                required: true
                        	},
                        	keySecret: {
                                required: true
                        	}
	                    }                                        
	                });
        	}
        	
        	function init() {
        		var message = '${message}';
        		var saveOk = '${saveOk}';
        		if (null != message && undefined != message && '' != message) {
        			$("#info").html(message);
 			   		$("#infoModal").modal("show");
        		}
        		if (saveOk=="1") {
        			setTimeout(function () {
     					back();
                    }, 2000);
        		}
        	}
        	
        	function back(){
        		var menuId = '${currMenuId}';
	         	window.location = ctx +"/estate/list?menuId=" + menuId;
	        }
        </script>
    </body>
</html>